Applying a Model





Kerry Back

Overview

  • Can save a trained model.
  • Load it and make predictions for new data.
  • Rank on predictions and trade (more later).
  • Important to interpret the model
    • What combinations of features does it like/dislike?
    • What industries does it like/dislike?

Repeat prior example

  • Use roeq and mom12m for 2021-01 as before.
  • Predict rnk as before.
  • Use a neural net with two hidden layers: 4 neurons in the first and 2 in the second.

Define and fit model

from sklearn.neural_network import MLPRegressor

X = data[["roeq", "mom12m"]]
y = data["rnk"]

model = MLPRegressor(
  hidden_layer_sizes=(4, 2),
  random_state=0
)
model.fit(X,y)